﻿--#include "data\functions\Boss\PersonBossCommon.lua" once			--个人BOSS
--#include "data\functions\Boss\BossSoulCommon.lua" once			--兽魂功能（点亮珠子）
----#include "data\functions\Boss\BossHomeCommon.lua" once			--BOSS之家
--#include "data\functions\Boss\MayaPalaceCommon.lua" once			--玛雅神殿
--#include "data\functions\Boss\LockBossCommon.lua" once			--锁妖塔
--#include "data\functions\Boss\StoneTombPigCommon.lua" once		--石墓烧猪
--#include "data\functions\Boss\BossAttackCommon.lua" once			--BOSS来袭
--#include "data\functions\Boss\ArenaBoss.lua" once					--擂台BOSS
--#include "data\functions\Boss\BloodFight.lua" once				--血战到底
--#include "data\functions\Boss\HuntBossTreasure.lua" once			--打宝地图
--#include "data\functions\Boss\TempleWoMa.lua" once			    --神殿沃玛
--#include "data\functions\Boss\WorldBossCommon.lua" once			--世界BOSS
--#include "data\functions\Boss\BossWanted.lua" once             	--boss悬赏
--#include "data\functions\Boss\GodShieldBossCommon.lua" once		--英雄神盾副本
--#include "data\functions\Activity\OpenServer\OpenServerAdvertisementPage.lua" once        --开服广告页

--#include "data\functions\Cross\CrossBossAttack.Lua" once			--跨服BOSS来袭

--[[BOSS相关操作
enum tagBossOP
{
	gGetAllBossAlive		= 1,					//获取全部存活的BOSS（主要供AliveBossConfig使用）
	gEnterPersonBossFuben	= 2,					//进入个人BOSS副本
	gGetPersonBossAward		= 3,					//领取个人BOSS副本奖励(不使用，走通用面板，消息(0,10))
	gTelToSceneBoss			= 4,					//传送到场景BOSS
	gGetBossSoulData		= 5,					//请求兽魂数据
	gOpenBossSoulBead		= 6,					//点亮兽魂珠子
	gEnterMayaPalace		= 7,					//进入玛雅神殿
	gEnterLockBoss			= 8,					//进入锁妖塔
	gStoneTombPigBuy		= 9,					//[石墓烧猪]购买法师法神
	gStoneTombPigFreshMon	= 10,					//[石墓烧猪]启动刷怪
	gStoneTombPigGetAward	= 11,					//[石墓烧猪]领奖
	gPersonBossGetData		= 12,					//[个人BOSS]获取数据
	gStoneTombPigAddBuyTimes= 13,					//[石墓烧猪]增加购买法师法神的次数
	gBossSoulDraw			= 14,					//[新兽魂]抽取兽魂
	gStoneTombPigOneKeySet	= 15,					//[石墓烧猪]一键放置
	gGetAwardBossData		= 16,					//[封印BOSS]获取数据
	gLockBossGetReliveTime  = 17,					//[锁妖塚]获取BOSS复活时间
	gBloodFightEnter		= 18,					//[血战不退]进入房间
	gBloodFightOp			= 19,					//[血战不退]操作
	gSkyTowerOp				= 20,					//[通天塔]操作
	gEnterBossHuntTreasure	= 21,					//[中级打宝地图]进入场景
	gGetBossWantedData		= 22,					//[BOSS悬赏]获取BOSS悬赏数据
};
]]

function GmDoBoss( sysarg, flag, param )
	print("GmDoBoss, flag="..flag..", param="..param)
	if flag == 1 then
		printCallStack()
	elseif flag == 2 then
		if param == 1 then				--退出副本
			Actor.exitFuben(sysarg) 	--正式退出副本，在此之前都是在副本中
		elseif param == 2 then			--退出场景
			BackToMainCity( sysarg )	--默认返回主城
		end
	elseif flag == 3 then
		local sVar = Actor.getStaticVar(sysarg)
		sVar.personBoss = {}
		SendPersonBossData( sysarg )
	elseif flag == 4 then
		SendAllAliveBoss( sysarg )
	elseif flag == 5 then
		EnterPersonBoss( sysarg, param )
	elseif flag == 6 then
		GetPersonBossAward( sysarg, param )
	elseif flag == 7 then
		SendPersonBossData( sysarg )
	elseif flag == 8 then
		TelToSceneBoss( sysarg, param, 0 )
	elseif flag == 9 then
		TelToSceneBoss( sysarg, param, 1 )
	elseif flag == 10 then
		SendBossSoulData( sysarg )
	elseif flag == 11 then
		OpenBossSoulBead( sysarg )
	elseif flag == 12 then
		Actor.setBossSoulBead( sysarg, 0, 0 )
		SendBossSoulData( sysarg )
	elseif flag == 15 then
		StoneTomePigFreshMonByHand( sysarg )
	elseif flag == 16 then
		StoneTomePigBuy( sysarg, param )
	elseif flag == 17 then			--[石墓烧猪]弹出奖励结算面板
		StoneTomePigOpenAward( sysarg )
	elseif flag == 18 then			--[石墓烧猪]领取第N档次的奖励
		StoneTomePigGetAward( sysarg, param, true )
	elseif flag == 19 then
		if param == 0 then
			AttackBossStart()
		else
			AttackBossFreshBatchMonsters( param )
		end
	elseif flag == 20 then
		local fubenPtr 		= Actor.getFubenPrt( sysarg )
		local fubenHandle	= Fuben.getFubenHandle(fubenPtr) or 0
		local sceneId		= Actor.getSceneId( sysarg )
		local monsterNum	= System.getMonsterCountById( param, sceneId, 0 )
		print("GmDoBoss, monsterId="..param..", monsterNum="..monsterNum..", sceneId="..sceneId)
	elseif flag == 21 then				--抽取兽魂
		DrawBossSoul( sysarg )
	elseif flag == 22 then
		if param == 0 then
			SendAllBossSoul( sysarg )
		else
			SendOneBossSoul( sysarg, param )
		end
	elseif flag == 23 then
		SetActorDailyDoneTimes( sysarg, enDailyOpTimes_DrawBossSoul, 0 )
	elseif flag == 24 then
		local valueIn1 = 11
		local valueIn2 = 22
		local valueIn3 = 33
		local valueIn4 = 44
		local value = System.makeUChar2UInt(valueIn1, valueIn2, valueIn3, valueIn4)
		local value1, value2, value3, value4 = System.makeUInt2UChar( value, 0,0,0,0 )
		print("GmDoBoss, value="..value..", value1="..value1..", value2="..value2..", value3="..value3..", value4="..value4)
	elseif flag == 25 then
		local loginDays = Actor.getLoginDays(sysarg)
		print("GmDoBoss, loginDays="..loginDays)
	elseif flag == 26 then
		CombineServerFreshBoss( param )
	elseif flag == 27 then
		SendLockBossReliveTime( sysarg )		--下发锁妖塚BOSS复活时间
	elseif flag == 28 then
		AttackBossFreshBatchMonsters( param )	--BOSS来袭
	elseif flag == 29 then
		if param == 0 then
			CrossAttackBossStart()
		else
			CrossAttackBossFreshBatchMonsters( param )
		end
	elseif flag == 30 then
		local bossIdx = param
		ChallengeArenaBoss( sysarg, bossIdx )
	elseif flag == 31 then
		local sceneId = param
		if System.hasScene( sceneId, 0 ) then
			print("warning, scene["..sceneId.."] is exist")
		else
			print("warning, scene["..sceneId.."] is not exist")
		end
	elseif flag == 32 then
		local roomIdx = param
		EnterBloodFight( sysarg, roomIdx )
	elseif flag == 33 then
		EnterExepMoZun( sysarg ) 				--进入体验魔尊战场（测试用）
	elseif flag == 34 then
		if param == 0 then
  			OnTempleWoMaBegin() 				   --进入神殿沃玛（测试用）
  		else
  			CleanTempleWoMaEnterFlag( sysarg )    --重置进入神殿沃玛的标记（测试用）
  		end
  	elseif flag == 35 then
  		if param == 0 then
  			WorldBossBegin( ) 				   --世界BOSS刷新（测试用）
  		else
  			WorldBossStop( )					--世界BOSS停止（测试用）
  		end
  	elseif flag == 36 then						--BOSS悬赏
  		OnBossWantedDailyProc( )
  	elseif flag == 37 then
  		if param == 0 then
  			SendBossWantedData( sysarg )			--下发击杀数据
  		elseif param == 1 then
  			ClearBossWantedData( sysarg )			--清除BOSS悬赏数据
  		elseif param == 2 then
  			--SendBossWantedAwardsToPalyers( )      --暂时不用
  		end
  	elseif flag == 38 then
  		
	end
end

---Boss事件
BossOpFuncList = {}

EventCallDispatcher.handleBossOp = function (sysarg, args)
	--print("EventCallDispatcher.handleBossOp...")
	if args[1] == nil then return end  
	local func = BossOpFuncList[args[1]]
	if func ~= nil then
		func(sysarg, args) 
	end
end

--获取刷出的BOSS（主要供AliveBossConfig使用）
BossOpFuncList[gGetAllBossAlive] = function(sysarg,args)
	SendAllAliveBoss( sysarg )
end

--进入个人BOSS副本
BossOpFuncList[gEnterPersonBossFuben] = function(sysarg,args)
	local bossIdx 	= args[2]
	EnterPersonBoss( sysarg, bossIdx )
end

--领取个人BOSS副本奖励
BossOpFuncList[gGetPersonBossAward] = function(sysarg,args)
	local awardRate = args[2]
	GetPersonBossAward( sysarg, awardRate )
end

--传送到场景BOSS
BossOpFuncList[gTelToSceneBoss] = function(sysarg,args)
	local bossId 	= args[2]
	local payFlag 	= args[3]
	TelToSceneBoss( sysarg, bossId, payFlag )
end

--[[获取兽魂数据
]]
BossOpFuncList[gGetBossSoulData] = function(sysarg,args)
	SendAllBossSoul( sysarg )
end

--打开兽魂珠子
BossOpFuncList[gOpenBossSoulBead] = function(sysarg,args)
	OpenBossSoulBead( sysarg )
end

--进入玛雅神殿
BossOpFuncList[gEnterMayaPalace] = function(sysarg,args)
	local palaceIdx = args[2]
	EnterMayaPalace( sysarg, palaceIdx )
end

--进入锁妖塔
BossOpFuncList[gEnterLockBoss] = function(sysarg,args)
	EnterLockBoss( sysarg )
end

--[锁妖塚]请求锁妖塚BOSS的复活时间
BossOpFuncList[gLockBossGetReliveTime] = function(sysarg,args)
	SendLockBossReliveTime( sysarg )
end

--[石墓烧猪]购买法师法神
BossOpFuncList[gStoneTombPigBuy] = function(sysarg,args)
	local buyType 	= args[2]
	local fubenPtr 	= nil
	local setPos 	= nil
	local byHand 	= true
	local needNotify= true
	StoneTomePigBuy( fubenPtr, sysarg, buyType, setPos, byHand, needNotify )
end

--[石墓烧猪]启动刷怪
BossOpFuncList[gStoneTombPigFreshMon] = function(sysarg,args)
	StoneTomePigFreshMonByHand( sysarg )
end

--[石墓烧猪]领奖
BossOpFuncList[gStoneTombPigGetAward] = function(sysarg,args)
	local awardIdx = args[2]
	StoneTomePigGetAward( sysarg, awardIdx, true )
end

--[个人BOSS]获取数据
BossOpFuncList[gPersonBossGetData] = function(sysarg,args)
	SendPersonBossData( sysarg )
end

--[石墓烧猪]增加购买法师法神的次数
BossOpFuncList[gStoneTombPigAddBuyTimes] = function(sysarg,args)
	local addType = args[2]
	StoneTomePigAddBuyTimes( sysarg, addType )
end

--[新兽魂]抽取兽魂
BossOpFuncList[gBossSoulDraw] = function(sysarg,args)
	DrawBossSoul( sysarg )
end


--[石墓烧猪]一键放置
BossOpFuncList[gStoneTombPigOneKeySet] = function(sysarg,args)
	local fubenPtr 	= nil
	local byHand 	= true
	StoneTombPigOneKeySet( fubenPtr, sysarg, byHand )
end

--[封印BOSS]获取数据
BossOpFuncList[gGetAwardBossData] = function(sysarg,args)
	SendAwardBossData( sysarg )
end

--[血战到底]进入BOSS房间
BossOpFuncList[gBloodFightEnter] = function(sysarg,args)
	local roomIdx = args[2]
	EnterBloodFight( sysarg, roomIdx )
end

--[血战到底]BOSS操作
BossOpFuncList[gBloodFightOp] = function(sysarg,args)
	local opType = args[2]				--1-鼓舞，2-刷新
	BloodFightOp( sysarg, opType )
end

--[通天塔]操作
BossOpFuncList[gSkyTowerOp] = function(sysarg,args)
	local opType = args[2]				--1-鼓舞，2-刷新
	SkyTowerOp( sysarg, opType )
end


--[中级打宝地图]进入场景
BossOpFuncList[gEnterBossHuntTreasure] = function(sysarg,args)
	local huntIdx = args[2]				--1-鼓舞，2-刷新
	EnterHuntBossTreasure( sysarg, huntIdx )
end

--[BOSS悬赏]获取BOSS悬赏数据
BossOpFuncList[gGetBossWantedData] = function(sysarg,args)
	SendBossWantedData( sysarg )
end


EventCallDispatcher.registerEventCall(aeBossOp, EventCallDispatcher.handleBossOp)
